home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / piano.zip / SAVENOTE.CPP < prev    next >
C/C++ Source or Header  |  1992-09-06  |  866b  |  45 lines

  1. // filename    SAVENOTE.CPP
  2. // author    Robert Upleger
  3. // intent    Used to store a song on an external file that can
  4. //        be used with "PIANO.CPP" program.
  5. //
  6.  
  7. #include <conio.h>        // for getch()
  8. #include <dos.h>        // for delay()
  9. #include <fstream.h>        // for cout, etc
  10.  
  11.  
  12. class Note
  13.     {
  14.     public:
  15.         char letter ;
  16.         float delay ;
  17.         void getnote()
  18.             {
  19.             cout << "\nEnter letter: " ; cin >> letter ;
  20.             cout << "\nEnter delay: " ; cin >> delay ;
  21.             }
  22.         void shownote()
  23.             {
  24.             cout << "\nLetter : " << letter ;
  25.             cout << "\nDelay  : " << delay ;
  26.             }
  27.     };
  28.  
  29.  
  30. void main()
  31.     {
  32.     char ch ;
  33.     Note note ;
  34.     fstream file ;
  35.     file.open( "A:SONG1.DAT" , ios::app | ios::out | ios::in ) ;
  36.     do
  37.         {
  38.         note.getnote() ;
  39.         file.write( (char*)¬e, sizeof( note ) ) ;
  40.         cout << "\nEnter another note (y/n)? " ;
  41.         cin >> ch ;
  42.         }
  43.     while ( ch == 'y' ) ;
  44.     }
  45.